
import 'db_manger.dart';
import 'package:sqflite/sqflite.dart';

abstract class DbProvider{
  bool isTableExits=false;
  tableSqlString();
  tableName();
  tableBaseString(String name,String columnId){
    return '''
    create table $name (
    $columnId integer primary key autoincrement,
    ''';
  }
  Future<Database> getDataBase() async{
    return await open();
  }
  //@mustCallSuper
  prepare(name,String createSql) async{
    isTableExits=await DbManger.isTbleExits(name);
    if(!isTableExits){
      Database db= await DbManger.getCurrentDatabase();
      return await db.execute(createSql);
    }
  }
  //@mustCallSuper
  open() async{
    if(!isTableExits){
      prepare(tableName(), tableSqlString());
    }
    return await DbManger.getCurrentDatabase();
  }
}